package de.tabuma.customer.controller;

import de.tabuma.customer.*;
import de.tabuma.customer.entity.*;
import de.tabuma.customer.logik.*;
import de.tabuma.customer.view.*;

import de.tabuma.lib.tabumacontroller;

import java.io.*;
import java.util.*;
import java.util.logging.*;
import javax.servlet.*;
import javax.servlet.http.*;
import com.google.appengine.api.users.*;

/**
 *
 * @author alefen
 */
public class controller extends tabumacontroller {

    private static final Logger log = Logger.getLogger(controller.class.getName());

    public controller(String servlet, Hashtable parameter) {
        super(servlet, parameter);
    }

    public void navigate(ServletContext context, HttpServletRequest request, HttpServletResponse response, PrintWriter out) {
        String requestParam = request.getParameter(constants.paramName);
        if(requestParam==null) {
            requestParam = ""+constants.ACTION_LIST;
        }

        int requestParamInt = Integer.valueOf(requestParam).intValue();
        log.warning("requestParamInt:"+requestParamInt);

        switch(requestParamInt) {
            case constants.ACTION_LIST:
                log.warning("test");
                listController lc = new listController(this.getServlet(), this.getParameter());
                lc.navigate(context, request, response, out);
                break;
            case constants.ACTION_CREATE:
                log.warning("test1");
                createController cc = new createController(this.getServlet(), this.getParameter());
                cc.navigate(context, request, response, out);
                break;
            case constants.ACTION_UPDATE:
                updateController uc = new updateController(this.getServlet(), this.getParameter());
                uc.navigate(context, request, response, out);
                break;
            case constants.ACTION_REMOVE:
                removeController rc = new removeController(this.getServlet(), this.getParameter());
                rc.navigate(context, request, response, out);
                break;
        }

        view view = new view(this.getServlet(), this.getParameter());
        view.processRequest(context, request, response, out);
    }
    
}
